// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import App from './App';
import router from './router';

import 'es6-promise/auto';
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios';

Vue.use(ElementUI);
Vue.prototype.$http = axios;

// 拦截响应response，并做一些错误处理
axios.interceptors.response.use((response) => {
  const data = response.data;
  /*switch (data.code) {
   //未授权
   case 3:

   break;
   //会话超时
   case 4:
   sessionStorage.setItem("token", null);
   router.replace({
   path: "/login"
   });
   break;
   default:
   break;
   }*/
  return data;
}, function (err) {
  if (err.response.status == 404) {
    router.replace({
      path: "/login"
    });
  }
});

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: {App},
  template: '<App/>'
});
